package org.example.高兴之举;

import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

public class treeMap {
    public static void main(String[] args) {
        Map<String, String > map = new TreeMap<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return -o1.compareTo(o2);
            }
        });

        map.put("a","A");
        map.put("b","B");
        map.put("c","C");
        map.put("d","D");
        map.put("e","E");
        // 采用迭代器遍历
//        Iterator iterator = map.keySet().iterator();
//        while(iterator.hasNext()){
//            String key= (String) iterator.next();
//            System.out.println(map.get(key));
//        }
        for (String s : map.keySet()) {

            System.out.println(s+"-"+ map.get(s));
        }



    }


}
